-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix/Improvement for cases when a theme was selected but than removed #855
Fix/Improvement for cases when a theme was selected but than removed #855
Conversation
/** | ||
* @var Config $configHandler | ||
*/ | ||
$configHandler = icms::getInstance()->get('config'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call to undeclared method \icms::get
@@ -73,7 +77,7 @@ public function __construct() { | |||
|
|||
parent::__construct(); | |||
|
|||
foreach (\icms::getInstance()->get('smarty.resource') as $plugin) { | |||
foreach (icms::getInstance()->get('smarty.resource') as $plugin) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call to undeclared method \icms::get
@@ -84,7 +88,7 @@ public function __construct() { | |||
'modifier' => 'register_modifier', | |||
'compiler' => 'register_compiler_function', | |||
] as $type => $function) { | |||
foreach (\icms::getInstance()->get('smarty.' . $type) as $plugin) { | |||
foreach (icms::getInstance()->get('smarty.' . $type) as $plugin) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Call to undeclared method \icms::get
public function fetch($template = null, $cache_id = null, $compile_id = null, $parent = null) | ||
{ | ||
try { | ||
return parent::fetch($template, $cache_id, $compile_id, $parent); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reference to undeclared class \SmartyBC
{ | ||
try { | ||
return parent::fetch($template, $cache_id, $compile_id, $parent); | ||
} catch (SmartyException $exception) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catching undeclared class \SmartyException
} catch (SmartyException $exception) { | ||
if (strpos($exception->getMessage(), 'Unable to load template') === 0) { | ||
$this->handleDeletedTemplateSet($exception); | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The method fetch uses an else expression. Else is never necessary and you can simplify the code to work without else.
*/ | ||
private function handleDeletedTemplateSet(SmartyException $exception): void { | ||
$isAdmin = $this->getTemplateVars('icms_isadmin'); | ||
$themesList = $isAdmin ? ThemeFactory::getAdminThemesList() : ThemeFactory::getThemesList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using static access to class '\ImpressCMS\Core\View\Theme\ThemeFactory' in method 'handleDeletedTemplateSet'.
*/ | ||
private function handleDeletedTemplateSet(SmartyException $exception): void { | ||
$isAdmin = $this->getTemplateVars('icms_isadmin'); | ||
$themesList = $isAdmin ? ThemeFactory::getAdminThemesList() : ThemeFactory::getThemesList(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid using static access to class '\ImpressCMS\Core\View\Theme\ThemeFactory' in method 'handleDeletedTemplateSet'.
At current moment if theme was selected in site preferences and than theme folder was removed, user will not be able to access website and select different theme. So for these rare times, another theme will be selected automatically and user could access site.